package fm.last.api
{
    import flash.net.URLRequestMethod;
    import flash.net.URLVariables;
    
    import fm.last.Agent;
    import fm.last.RestAPI;
    
    /** This API only for subscriber. */
    final public class RadioAPI extends RestAPI
    {
        // those in comment are not implemented yet
        public static const RADIO_GET_PLAYLIST:String = "radio.getPlaylist";
        public static const RADIO_TUNE:String         = "radio.tune";
        
        public function RadioAPI(agent:Agent)
        {
            super(agent);
        }

        /* ********************************************************************/
        

        /** radio.getPlaylist */
        public function getPlaylist(onComplete:Function, 
                                   onError:Function,
                                   discovery:Boolean=false,
                                   rtp:Boolean=false):void
        {
            var urlVars:URLVariables = new URLVariables();
            urlVars["method"] = RadioAPI.RADIO_GET_PLAYLIST;
            urlVars["discovery"] = discovery;
            urlVars["rtp"] = rtp;
            requestAPI(URLRequestMethod.GET, urlVars, true, onComplete, onError);        
        }
        
        
        /** radio.tune */
        public function tune(onComplete:Function, 
                                   onError:Function,
                                   station:String,
                                   lang:String=null):void
        {
            var urlVars:URLVariables = new URLVariables();
            urlVars["method"] = RadioAPI.RADIO_TUNE;
            urlVars["station"] = station;
            if (lang!=null) urlVars["lang"] = lang;
            requestAPI(URLRequestMethod.POST, urlVars, true, onComplete, onError);        
        }


    }
}